// pages/kechengxiangqing/kechengxiangqing.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    current: 0,
    hiddenshouqi: true,
    titleList: ["课程详情", "课程列表", "名师介绍", "课堂交流", "课程评价"],
    // 课程详情数据
    courseDetailData: {},
    List: {
      // coursename : '',
      // subscriptionnotice:'',
      // courseintroduce:'',
      // coursetime:'',
      // coursemount:'',
      // tabularchart:'',
      // applicablepopulation:'',
      // learnharvest:'',
      // coursevideo:'',
      // readingquantity:'',
    },//课程详情
    coursemark: '',//用户评价的数量

    // List:[]
    listteacher: {},//咨询师信息
    listcoursemark: {},//课程评价
    listcourseproblem:{},//课堂交流问题
    listcoursereply:{},//课堂交流问题回复





  },


  shouqi() {
    this.setData({
      hiddenshouqi: !this.data.hiddenshouqi
    })
  },


  tiao() {
    wx.navigateTo({
      url: '../shizixiangqing/shizixiangqing',
    })
  },

  // 选择scroll-view中的标题事件
  chooseItem(e) {
    console.log(e.target.dataset.index)
    this.setData({
      current: e.target.dataset.index
    })
  },
  // swiper的change事件函数
  swiperChanged(e) {
    // console.log(e.detail.current)
    this.setData({
      current: e.detail.current
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */

  onLoad(options) {

    let that = this;
    wx.request({
      url: 'http://localhost:8080/course/findCourseById?id=1',
      method: 'GET',
      success: function (res) {
        console.log("课程详情：");
        console.log(res.data.data);
        that.setData({
          "List": res.data.data
        })
      },
    });
    wx.request({
      url: 'http://localhost:8080/coursemark/AllCourseMarks',
      success: function (res) {
        console.log("评论的总条数：");
        console.log(res.data.data);
        that.setData({
          "coursemark": res.data.data
        })
      }
    });
    wx.request({
      url: 'http://localhost:8080/teacher/findTeacherById?id=1',
      success: function (res) {
        console.log("咨询师信息");
        console.log(res.data.data);
        that.setData({
          "listteacher": res.data.data
        })
      }
    });
    wx.request({
      url: 'http://localhost:8080/coursemark/findAllCourseMark',
      success: function (res) {
        console.log("课程评价：");
        console.log(res.data.data);
        that.setData({
          "listcoursemark": res.data.data
        })
      }
    });
    wx.request({
      url: 'http://localhost:8080/courseproblem/findAllCourseProblem',
      success:function(res){
        console.log("课堂交流问题");
        console.log(res.data.data);
        that.setData({
          "listcourseproblem":res.data.data
        })
      }
    });
    wx.request({
      url: 'http://localhost:8080/CourseReply/findAllCourseReply',
      success:function(res){
        console.log("课堂交流问题回复");
        console.log(res.data.data);
        that.setData({
          "listcoursereply":res.data.data
        })
      }
    });


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})